import { isNumber, isArray, isString, omit } from 'lodash'

const k = [
  'reportMin',
  'reportMax',
  'readyMin',
  'readyMax',
  'readMin',
  'readMax',
  'receivedMax',
  'receivedMin'
]

export default (value, keys = []) => {
  let total = 0

  const {
    reportMin,
    reportMax,
    readyMin,
    readyMax,
    readMin,
    readMax,
    receivedMax,
    receivedMin
  } = value

  for (let key in omit(value, [...keys, k])) {
    if (isArray(value[key]) && value[key].length) {
      total += 1
    }

    if (isString(value[key])) {
      total += 1
    }
  }

  if (isNumber(reportMin) || isNumber(reportMax)) {
    total += 1
  }
  if (isNumber(readyMin) || isNumber(readyMax)) {
    total += 1
  }
  if (isNumber(readMin) || isNumber(readMax)) {
    total += 1
  }
  if (isNumber(receivedMin) || isNumber(receivedMax)) {
    total += 1
  }

  return total
}
